
import { constantRoutes, asyncRoutes } from '@/router'
export default {
  namespaced: true,
  state: {
    routes: [...constantRoutes]
  },
  mutations: {
    setRoutes(state, data) {
      state.routes = [...constantRoutes, ...data]
    }

  },
  actions: {
    filterRoutes(context, menus) {
      console.log(menus)
      const userAsyncroutes = []
      asyncRoutes.forEach(item => {
        if (menus.includes(item.name)) userAsyncroutes.push(item)
        console.log(userAsyncroutes, '路由55555555555')
      })
      userAsyncroutes.push({ path: '*', redirect: '/404', hidden: true })
      context.commit('setRoutes', userAsyncroutes)
      return userAsyncroutes
    }

  }
}
